\(\int (a+b x)^2 \sin (c+d x) \, dx\) [12]

   Optimal result
   Rubi [A] (verified)
   Mathematica [A] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [B] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 14, antiderivative size = 50 \[ \int (a+b x)^2 \sin (c+d x) \, dx=\frac {2 b^2 \cos (c+d x)}{d^3}-\frac {(a+b x)^2 \cos (c+d x)}{d}+\frac {2 b (a+b x) \sin (c+d x)}{d^2} \]

[Out]

2*b^2*cos(d*x+c)/d^3-(b*x+a)^2*cos(d*x+c)/d+2*b*(b*x+a)*sin(d*x+c)/d^2

Rubi [A] (verified)

Time = 0.03 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.00, number of steps used = 3, number of rules used = 2, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.143, Rules used = {3377, 2718} \[ \int (a+b x)^2 \sin (c+d x) \, dx=\frac {2 b (a+b x) \sin (c+d x)}{d^2}-\frac {(a+b x)^2 \cos (c+d x)}{d}+\frac {2 b^2 \cos (c+d x)}{d^3} \]

[In]

Int[(a + b*x)^2*Sin[c + d*x],x]

[Out]

(2*b^2*Cos[c + d*x])/d^3 - ((a + b*x)^2*Cos[c + d*x])/d + (2*b*(a + b*x)*Sin[c + d*x])/d^2

Rule 2718

Int[sin[(c_.) + (d_.)*(x_)], x_Symbol] :> Simp[-Cos[c + d*x]/d, x] /; FreeQ[{c, d}, x]

Rule 3377

Int[((c_.) + (d_.)*(x_))^(m_.)*sin[(e_.) + (f_.)*(x_)], x_Symbol] :> Simp[(-(c + d*x)^m)*(Cos[e + f*x]/f), x]
+ Dist[d*(m/f), Int[(c + d*x)^(m - 1)*Cos[e + f*x], x], x] /; FreeQ[{c, d, e, f}, x] && GtQ[m, 0]

Rubi steps \begin{align*} \text {integral}& = -\frac {(a+b x)^2 \cos (c+d x)}{d}+\frac {(2 b) \int (a+b x) \cos (c+d x) \, dx}{d} \\ & = -\frac {(a+b x)^2 \cos (c+d x)}{d}+\frac {2 b (a+b x) \sin (c+d x)}{d^2}-\frac {\left (2 b^2\right ) \int \sin (c+d x) \, dx}{d^2} \\ & = \frac {2 b^2 \cos (c+d x)}{d^3}-\frac {(a+b x)^2 \cos (c+d x)}{d}+\frac {2 b (a+b x) \sin (c+d x)}{d^2} \\ \end{align*}

Mathematica [A] (verified)

Time = 0.13 (sec) , antiderivative size = 57, normalized size of antiderivative = 1.14 \[ \int (a+b x)^2 \sin (c+d x) \, dx=\frac {-\left (\left (a^2 d^2+2 a b d^2 x+b^2 \left (-2+d^2 x^2\right )\right ) \cos (c+d x)\right )+2 b d (a+b x) \sin (c+d x)}{d^3} \]

[In]

Integrate[(a + b*x)^2*Sin[c + d*x],x]

[Out]

(-((a^2*d^2 + 2*a*b*d^2*x + b^2*(-2 + d^2*x^2))*Cos[c + d*x]) + 2*b*d*(a + b*x)*Sin[c + d*x])/d^3

Maple [A] (verified)

Time = 0.22 (sec) , antiderivative size = 61, normalized size of antiderivative = 1.22

method result size
risch \(-\frac {\left (d^{2} x^{2} b^{2}+2 a b \,d^{2} x +d^{2} a^{2}-2 b^{2}\right ) \cos \left (d x +c \right )}{d^{3}}+\frac {2 b \left (b x +a \right ) \sin \left (d x +c \right )}{d^{2}}\) \(61\)
parallelrisch \(\frac {2 \left (\frac {b x}{2}+a \right ) x \,d^{2} b \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )+4 b d \left (b x +a \right ) \tan \left (\frac {d x}{2}+\frac {c}{2}\right )+\left (-x^{2} b^{2}-2 a b x -2 a^{2}\right ) d^{2}+4 b^{2}}{d^{3} \left (1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}\) \(91\)
parts \(-\frac {b^{2} x^{2} \cos \left (d x +c \right )}{d}-\frac {2 a b x \cos \left (d x +c \right )}{d}-\frac {a^{2} \cos \left (d x +c \right )}{d}+\frac {2 b \left (a \sin \left (d x +c \right )-\frac {b c \sin \left (d x +c \right )}{d}+\frac {b \left (\cos \left (d x +c \right )+\left (d x +c \right ) \sin \left (d x +c \right )\right )}{d}\right )}{d^{2}}\) \(99\)
norman \(\frac {\frac {b^{2} x^{2} \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}-\frac {2 d^{2} a^{2}-4 b^{2}}{d^{3}}-\frac {b^{2} x^{2}}{d}+\frac {4 b^{2} x \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d^{2}}+\frac {4 a b \tan \left (\frac {d x}{2}+\frac {c}{2}\right )}{d^{2}}-\frac {2 a b x}{d}+\frac {2 a b x \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{d}}{1+\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )}\) \(130\)
derivativedivides \(\frac {-a^{2} \cos \left (d x +c \right )+\frac {2 a b c \cos \left (d x +c \right )}{d}+\frac {2 a b \left (\sin \left (d x +c \right )-\cos \left (d x +c \right ) \left (d x +c \right )\right )}{d}-\frac {b^{2} c^{2} \cos \left (d x +c \right )}{d^{2}}-\frac {2 b^{2} c \left (\sin \left (d x +c \right )-\cos \left (d x +c \right ) \left (d x +c \right )\right )}{d^{2}}+\frac {b^{2} \left (-\left (d x +c \right )^{2} \cos \left (d x +c \right )+2 \cos \left (d x +c \right )+2 \left (d x +c \right ) \sin \left (d x +c \right )\right )}{d^{2}}}{d}\) \(148\)
default \(\frac {-a^{2} \cos \left (d x +c \right )+\frac {2 a b c \cos \left (d x +c \right )}{d}+\frac {2 a b \left (\sin \left (d x +c \right )-\cos \left (d x +c \right ) \left (d x +c \right )\right )}{d}-\frac {b^{2} c^{2} \cos \left (d x +c \right )}{d^{2}}-\frac {2 b^{2} c \left (\sin \left (d x +c \right )-\cos \left (d x +c \right ) \left (d x +c \right )\right )}{d^{2}}+\frac {b^{2} \left (-\left (d x +c \right )^{2} \cos \left (d x +c \right )+2 \cos \left (d x +c \right )+2 \left (d x +c \right ) \sin \left (d x +c \right )\right )}{d^{2}}}{d}\) \(148\)
meijerg \(\frac {4 b^{2} \sqrt {\pi }\, \sin \left (c \right ) \left (\frac {x \left (d^{2}\right )^{\frac {3}{2}} \cos \left (d x \right )}{2 \sqrt {\pi }\, d^{2}}-\frac {\left (d^{2}\right )^{\frac {3}{2}} \left (-\frac {3 d^{2} x^{2}}{2}+3\right ) \sin \left (d x \right )}{6 \sqrt {\pi }\, d^{3}}\right )}{d^{2} \sqrt {d^{2}}}+\frac {4 b^{2} \sqrt {\pi }\, \cos \left (c \right ) \left (-\frac {1}{2 \sqrt {\pi }}+\frac {\left (-\frac {d^{2} x^{2}}{2}+1\right ) \cos \left (d x \right )}{2 \sqrt {\pi }}+\frac {d x \sin \left (d x \right )}{2 \sqrt {\pi }}\right )}{d^{3}}+\frac {4 b a \sqrt {\pi }\, \sin \left (c \right ) \left (-\frac {1}{2 \sqrt {\pi }}+\frac {\cos \left (d x \right )}{2 \sqrt {\pi }}+\frac {d x \sin \left (d x \right )}{2 \sqrt {\pi }}\right )}{d^{2}}+\frac {4 b a \sqrt {\pi }\, \cos \left (c \right ) \left (-\frac {d x \cos \left (d x \right )}{2 \sqrt {\pi }}+\frac {\sin \left (d x \right )}{2 \sqrt {\pi }}\right )}{d^{2}}+\frac {a^{2} \sin \left (c \right ) \sin \left (d x \right )}{d}+\frac {a^{2} \sqrt {\pi }\, \cos \left (c \right ) \left (\frac {1}{\sqrt {\pi }}-\frac {\cos \left (d x \right )}{\sqrt {\pi }}\right )}{d}\) \(224\)

[In]

int((b*x+a)^2*sin(d*x+c),x,method=_RETURNVERBOSE)

[Out]

-(b^2*d^2*x^2+2*a*b*d^2*x+a^2*d^2-2*b^2)/d^3*cos(d*x+c)+2*b*(b*x+a)*sin(d*x+c)/d^2

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 63, normalized size of antiderivative = 1.26 \[ \int (a+b x)^2 \sin (c+d x) \, dx=-\frac {{\left (b^{2} d^{2} x^{2} + 2 \, a b d^{2} x + a^{2} d^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right ) - 2 \, {\left (b^{2} d x + a b d\right )} \sin \left (d x + c\right )}{d^{3}} \]

[In]

integrate((b*x+a)^2*sin(d*x+c),x, algorithm="fricas")

[Out]

-((b^2*d^2*x^2 + 2*a*b*d^2*x + a^2*d^2 - 2*b^2)*cos(d*x + c) - 2*(b^2*d*x + a*b*d)*sin(d*x + c))/d^3

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 112 vs. \(2 (48) = 96\).

Time = 0.20 (sec) , antiderivative size = 112, normalized size of antiderivative = 2.24 \[ \int (a+b x)^2 \sin (c+d x) \, dx=\begin {cases} - \frac {a^{2} \cos {\left (c + d x \right )}}{d} - \frac {2 a b x \cos {\left (c + d x \right )}}{d} + \frac {2 a b \sin {\left (c + d x \right )}}{d^{2}} - \frac {b^{2} x^{2} \cos {\left (c + d x \right )}}{d} + \frac {2 b^{2} x \sin {\left (c + d x \right )}}{d^{2}} + \frac {2 b^{2} \cos {\left (c + d x \right )}}{d^{3}} & \text {for}\: d \neq 0 \\\left (a^{2} x + a b x^{2} + \frac {b^{2} x^{3}}{3}\right ) \sin {\left (c \right )} & \text {otherwise} \end {cases} \]

[In]

integrate((b*x+a)**2*sin(d*x+c),x)

[Out]

Piecewise((-a**2*cos(c + d*x)/d - 2*a*b*x*cos(c + d*x)/d + 2*a*b*sin(c + d*x)/d**2 - b**2*x**2*cos(c + d*x)/d
+ 2*b**2*x*sin(c + d*x)/d**2 + 2*b**2*cos(c + d*x)/d**3, Ne(d, 0)), ((a**2*x + a*b*x**2 + b**2*x**3/3)*sin(c),
 True))

Maxima [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 141 vs. \(2 (50) = 100\).

Time = 0.19 (sec) , antiderivative size = 141, normalized size of antiderivative = 2.82 \[ \int (a+b x)^2 \sin (c+d x) \, dx=-\frac {a^{2} \cos \left (d x + c\right ) + \frac {b^{2} c^{2} \cos \left (d x + c\right )}{d^{2}} - \frac {2 \, a b c \cos \left (d x + c\right )}{d} - \frac {2 \, {\left ({\left (d x + c\right )} \cos \left (d x + c\right ) - \sin \left (d x + c\right )\right )} b^{2} c}{d^{2}} + \frac {2 \, {\left ({\left (d x + c\right )} \cos \left (d x + c\right ) - \sin \left (d x + c\right )\right )} a b}{d} + \frac {{\left ({\left ({\left (d x + c\right )}^{2} - 2\right )} \cos \left (d x + c\right ) - 2 \, {\left (d x + c\right )} \sin \left (d x + c\right )\right )} b^{2}}{d^{2}}}{d} \]

[In]

integrate((b*x+a)^2*sin(d*x+c),x, algorithm="maxima")

[Out]

-(a^2*cos(d*x + c) + b^2*c^2*cos(d*x + c)/d^2 - 2*a*b*c*cos(d*x + c)/d - 2*((d*x + c)*cos(d*x + c) - sin(d*x +
 c))*b^2*c/d^2 + 2*((d*x + c)*cos(d*x + c) - sin(d*x + c))*a*b/d + (((d*x + c)^2 - 2)*cos(d*x + c) - 2*(d*x +
c)*sin(d*x + c))*b^2/d^2)/d

Giac [A] (verification not implemented)

none

Time = 0.28 (sec) , antiderivative size = 65, normalized size of antiderivative = 1.30 \[ \int (a+b x)^2 \sin (c+d x) \, dx=-\frac {{\left (b^{2} d^{2} x^{2} + 2 \, a b d^{2} x + a^{2} d^{2} - 2 \, b^{2}\right )} \cos \left (d x + c\right )}{d^{3}} + \frac {2 \, {\left (b^{2} d x + a b d\right )} \sin \left (d x + c\right )}{d^{3}} \]

[In]

integrate((b*x+a)^2*sin(d*x+c),x, algorithm="giac")

[Out]

-(b^2*d^2*x^2 + 2*a*b*d^2*x + a^2*d^2 - 2*b^2)*cos(d*x + c)/d^3 + 2*(b^2*d*x + a*b*d)*sin(d*x + c)/d^3

Mupad [B] (verification not implemented)

Time = 5.93 (sec) , antiderivative size = 84, normalized size of antiderivative = 1.68 \[ \int (a+b x)^2 \sin (c+d x) \, dx=\frac {\cos \left (c+d\,x\right )\,\left (2\,b^2-a^2\,d^2\right )}{d^3}-\frac {b^2\,x^2\,\cos \left (c+d\,x\right )}{d}+\frac {2\,a\,b\,\sin \left (c+d\,x\right )}{d^2}+\frac {2\,b^2\,x\,\sin \left (c+d\,x\right )}{d^2}-\frac {2\,a\,b\,x\,\cos \left (c+d\,x\right )}{d} \]

[In]

int(sin(c + d*x)*(a + b*x)^2,x)

[Out]

(cos(c + d*x)*(2*b^2 - a^2*d^2))/d^3 - (b^2*x^2*cos(c + d*x))/d + (2*a*b*sin(c + d*x))/d^2 + (2*b^2*x*sin(c +
d*x))/d^2 - (2*a*b*x*cos(c + d*x))/d